/*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.

Copyright (c) 2023-present Kaleidos INC
*/

:host {
  --label-color: var(--color-gray80);
  --label-color-error: var(--color-red);
  --label-font-weight: var(--font-weight-medium);
  --label-focus-color: var(--color-secondary);
}

label {
  color: var(--label-color);
  line-height: 1.5;
  margin-block-end: var(--spacing-4);
  margin-inline-start: var(--spacing-4);
  min-inline-size: 0;

  &:not(.readonly) {
    font-weight: var(--label-font-weight);
  }

  &[for]:not(.readonly) {
    cursor: pointer;
  }
}

:host:focus-within:not(.readonly) label {
  color: var(--label-focus-color);
}

:host.invalid.show-errors:focus-within {
  &.update-on-submit.submitted,
  &.update-on-blur.dirty,
  &.update-on-change.dirty,
  &.update-on-blur.touched,
  &.update-on-change.touched {
    & label {
      color: var(--label-color-error);
    }
  }
}
